
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第八章：流程控制 ·  GO语言 web服务器区块链开发工程师就业班课程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="波波">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-navigator/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Chapter9/函数.html" />
    
    
    <link rel="prev" href="../Chapter7/运算符.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.shxdledu.cn/single/About-Me" target="_blank" class="custom-link">关于作者</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Chapter1/base.html">
            
                <a href="../Chapter1/base.html">
            
                    
                    第一章：区块链基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../Chapter2/base.html">
            
                <a href="../Chapter2/base.html">
            
                    
                    第二章：初识Go语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Chapter2/GO语言介绍.html">
            
                <a href="../Chapter2/GO语言介绍.html">
            
                    
                    第1节：GO语言介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Chapter2/环境安装.html">
            
                <a href="../Chapter2/环境安装.html">
            
                    
                    第2节：环境安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Chapter2/第一个GO程序.html">
            
                <a href="../Chapter2/第一个GO程序.html">
            
                    
                    第3节：第一个GO程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Chapter2/学习资料.html">
            
                <a href="../Chapter2/学习资料.html">
            
                    
                    第4节：学习资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Chapter3/注释.html">
            
                <a href="../Chapter3/注释.html">
            
                    
                    第三章：注释
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Chapter3/注释作用.html">
            
                <a href="../Chapter3/注释作用.html">
            
                    
                    第1节：注释作用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Chapter3/注释分类.html">
            
                <a href="../Chapter3/注释分类.html">
            
                    
                    第2节：注释分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Chapter3/学习资料.html">
            
                <a href="../Chapter3/学习资料.html">
            
                    
                    第3节：学习资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Chapter4/变量.html">
            
                <a href="../Chapter4/变量.html">
            
                    
                    第四章：变量
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Chapter4/什么叫变量.html">
            
                <a href="../Chapter4/什么叫变量.html">
            
                    
                    第1节：什么叫变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Chapter4/变量类型.html">
            
                <a href="../Chapter4/变量类型.html">
            
                    
                    第2节：变量类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Chapter4/变量声明.html">
            
                <a href="../Chapter4/变量声明.html">
            
                    
                    第3节：变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Chapter4/变量初始化.html">
            
                <a href="../Chapter4/变量初始化.html">
            
                    
                    第4节：变量初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Chapter4/变量赋值.html">
            
                <a href="../Chapter4/变量赋值.html">
            
                    
                    第5节：变量赋值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../Chapter4/自动推导类型.html">
            
                <a href="../Chapter4/自动推导类型.html">
            
                    
                    第6节：自动推导类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../Chapter4/多重赋值匿名变量.html">
            
                <a href="../Chapter4/多重赋值匿名变量.html">
            
                    
                    第7节：多重赋值匿名变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../Chapter4/数据置换.html">
            
                <a href="../Chapter4/数据置换.html">
            
                    
                    第8节：数据置换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../Chapter4/输出格式.html">
            
                <a href="../Chapter4/输出格式.html">
            
                    
                    第9节：输出格式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../Chapter4/接收输入.html">
            
                <a href="../Chapter4/接收输入.html">
            
                    
                    第10节：接收输入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../Chapter4/变量命名规范.html">
            
                <a href="../Chapter4/变量命名规范.html">
            
                    
                    第11节：变量命名规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../Chapter4/变量命名规范.html">
            
                <a href="../Chapter4/变量命名规范.html">
            
                    
                    第12节：变量命名规范
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Chapter5/基础数据类型.html">
            
                <a href="../Chapter5/基础数据类型.html">
            
                    
                    第五章：基础数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Chapter6/常量.html">
            
                <a href="../Chapter6/常量.html">
            
                    
                    第六章：常量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../Chapter7/运算符.html">
            
                <a href="../Chapter7/运算符.html">
            
                    
                    第七章：运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.9" data-path="流程控制.html">
            
                <a href="流程控制.html">
            
                    
                    第八章：流程控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../Chapter9/函数.html">
            
                <a href="../Chapter9/函数.html">
            
                    
                    第九章：函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../Chapter10/工程管理.html">
            
                <a href="../Chapter10/工程管理.html">
            
                    
                    第十章：工程管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../Chapter11/数据格式.html">
            
                <a href="../Chapter11/数据格式.html">
            
                    
                    第十一章：数据格式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../Chapter12/面向对象.html">
            
                <a href="../Chapter12/面向对象.html">
            
                    
                    第十二章：面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../Chapter13/异常处理.html">
            
                <a href="../Chapter13/异常处理.html">
            
                    
                    第十三章：异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../Chapter14/文本文件处理.html">
            
                <a href="../Chapter14/文本文件处理.html">
            
                    
                    第十四章：文本文件处理
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第八章：流程控制</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;&#x516B;&#x7AE0;&#xFF1A;&#x6D41;&#x7A0B;&#x63A7;&#x5236;">&#x7B2C;&#x516B;&#x7AE0;&#xFF1A;&#x6D41;&#x7A0B;&#x63A7;&#x5236;</h1>
<p>&#x524D;&#x9762;&#x6211;&#x4EEC;&#x5199;&#x7684;&#x7A0B;&#x5E8F;&#x90FD;&#x662F;&#x4ECE;&#x7B2C;&#x4E00;&#x884C;&#x5F00;&#x59CB;&#x6267;&#x884C;&#xFF0C;&#x4E00;&#x76F4;&#x6267;&#x884C;&#x5230;&#x672B;&#x5C3E;&#xFF0C;&#x4E00;&#x884C;&#x4E00;&#x884C;&#x7684;&#x987A;&#x5E8F;&#x6267;&#x884C;&#x4E0B;&#x6765;&#xFF0C;&#x8FD9;&#x79CD;&#x6267;&#x884C;&#x7ED3;&#x6784;&#x53EB;&#x987A;&#x5E8F;&#x6267;&#x884C;&#x7ED3;&#x6784;&#x3002;
GO&#x8BED;&#x8A00;&#x9664;&#x4E86;&#x6709;&#x987A;&#x5E8F;&#x7ED3;&#x6784;&#xFF0C;&#x8FD8;&#x6709;&#x9009;&#x62E9;&#x7ED3;&#x6784;&#xFF0C;&#x5FAA;&#x73AF;&#x7ED3;&#x6784;&#x3002;</p>
<ul>
<li>&#x987A;&#x5E8F;&#x7ED3;&#x6784;&#xFF1A;&#x7A0B;&#x5E8F;&#x6309;&#x987A;&#x5E8F;&#x6267;&#x884C;&#xFF0C;&#x4E0D;&#x53D1;&#x751F;&#x8DF3;&#x8F6C;&#x3002;</li>
<li>&#x9009;&#x62E9;&#x7ED3;&#x6784;&#xFF1A;&#x4F9D;&#x636E;&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#xFF0C;&#x6709;&#x9009;&#x62E9;&#x7684;&#x6267;&#x884C;&#x76F8;&#x5E94;&#x529F;&#x80FD;&#x3002;</li>
<li>&#x5FAA;&#x73AF;&#x7ED3;&#x6784;&#xFF1A;&#x4F9D;&#x636E;&#x6761;&#x4EF6;&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#xFF0C;&#x5FAA;&#x73AF;&#x591A;&#x6B21;&#x6267;&#x884C;&#x67D0;&#x6BB5;&#x4EE3;&#x7801;&#x3002;</li>
</ul>
<p>&#x4E0B;&#x9762;&#x5148;&#x8BB2;&#x89E3;&#x9009;&#x62E9;&#x7ED3;&#x6784;&#xFF1A;</p>
<h2 id="1:_01if&#x6761;&#x4EF6;&#x8BED;&#x53E5;">1. 1: 01if&#x6761;&#x4EF6;&#x8BED;&#x53E5;</h2>
<pre class="language-"><code>package main

import (
    &quot;fmt&quot;
)

func main0101() {

    //if &#x8868;&#x8FBE;&#x5F0F;
    //{
    //&#x4EE3;&#x7801;&#x4F53;
    //}

    var score int

    fmt.Scan(&amp;score)

    //if score &gt; 700 {
    //    fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x6E05;&#x534E;&quot;)
    //}

    //if score &gt; 700 {
    //    fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x6E05;&#x534E;&quot;)
    //} else {
    //    fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x65AF;&#x5766;&#x798F;&quot;)
    //}

    if score &gt; 700 {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x6E05;&#x534E;&quot;)
    } else if score &gt; 680 {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x5317;&#x5927;&quot;)
    } else if score &gt; 650 {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x4EBA;&#x5927;&quot;)
    } else {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x65AF;&#x5766;&#x798F;&quot;)
    }

    var m int

}
</code></pre><h2 id="2:if&#x8BED;&#x53E5;&#x5D4C;&#x5957;">2. 2:if&#x8BED;&#x53E5;&#x5D4C;&#x5957;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0201() {
    var score int

    fmt.Scan(&amp;score)

    if score &gt; 700 {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x6E05;&#x534E;&quot;)
        if score &gt; 720 {
            fmt.Println(&quot;&#x6211;&#x8981;&#x5B66;&#x6316;&#x6398;&#x673A;&quot;)
        } else if score &gt; 710 {
            fmt.Println(&quot;&#x6211;&#x8981;&#x5B66;&#x7F8E;&#x5BB9;&#x7F8E;&#x53D1;&quot;)
        } else {
            fmt.Println(&quot;&#x6211;&#x8981;&#x5B66;&#x4E60;&#x6C7D;&#x4FEE;&quot;)
        }

    } else if score &gt; 680 {
        fmt.Println(&quot;&#x6211;&#x8981;&#x4E0A;&#x5317;&#x5927;&quot;)

        if score &gt; 690 {
            fmt.Println(&quot;&#x6211;&#x8981;&#x5B66;&#x76D7;&#x5893;&quot;)
        } else {
            fmt.Println(&quot;&#x6211;&#x8981;&#x5B66;&#x4E60;go&#x8BED;&#x8A00;&quot;)
        }
    }

}

//&#x4E09;&#x53EA;&#x5C0F;&#x732A;&#x79F0;&#x4F53;&#x91CD; &#x901A;&#x8FC7;&#x952E;&#x76D8;&#x8F93;&#x5165;&#x4E09;&#x53EA;&#x5C0F;&#x732A;&#x4F53;&#x91CD; &#x627E;&#x5230;&#x6700;&#x91CD;&#x7684;
func main() {

    var a, b, c int
    //10 8 12
    fmt.Scan(&amp;a, &amp;b, &amp;c)

    if a &gt; b {
        //a&#x91CD;
        if a &gt; c {
            fmt.Println(&quot;a&#x6700;&#x91CD;&quot;)
        } else {
            fmt.Println(&quot;c&#x6700;&#x91CD;&quot;)
        }
    } else {
        //b&#x91CD;
        if b &gt; c {
            fmt.Println(&quot;b&#x6700;&#x91CD;&quot;)
        } else {
            fmt.Println(&quot;c&#x6700;&#x91CD;&quot;)
        }
    }
}
//&#x6839;&#x636E;&#x5206;&#x6570; &gt;=90 A &gt;=80 B &gt;=70 C &gt;=60 D &#x4E0D;&#x53CA;&#x683C; E
</code></pre><h2 id="3:switch&#x5206;&#x652F;&#x8BED;&#x53E5;">3. 3:switch&#x5206;&#x652F;&#x8BED;&#x53E5;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0301() {

    //switch &#x53D8;&#x91CF;(&#x8868;&#x8FBE;&#x5F0F;) {
    //case &#x503C;1:
    //    &#x4EE3;&#x7801;&#x4F53;
    //  fallthrough
    //case &#x503C;2:
    //    &#x4EE3;&#x7801;&#x4F53;
    //default:
    //    &#x4EE3;&#x7801;&#x4F53;
    //}

    //&#x6839;&#x636E;&#x5206;&#x6570; &gt;=90 A &gt;=80 B &gt;=70 C &gt;=60 D &#x4E0D;&#x53CA;&#x683C; E

    var score int
    fmt.Scan(&amp;score)
    switch score / 10 {
    case 10:
        //fmt.Println(&quot;A&quot;)
        fallthrough
    case 9:
        fmt.Println(&quot;A&quot;)
    case 8:
        fmt.Println(&quot;B&quot;)
    case 7:
        fmt.Println(&quot;C&quot;)
    case 6:
        fmt.Println(&quot;D&quot;)
    default:
        fmt.Println(&quot;E&quot;)
    }
}
func main0302() {

    var score int
    fmt.Scan(&amp;score)

    switch {
    case score &gt;= 90:
        fmt.Println(&quot;A&quot;)
    case score &gt;= 80:
        fmt.Println(&quot;B&quot;)
    case score &gt;= 70:
        fmt.Println(&quot;C&quot;)
    case score &gt;= 60:
        fmt.Println(&quot;D&quot;)
    default:
        fmt.Println(&quot;E&quot;)

    }
}
func main0303() {
    var score int
    fmt.Scan(&amp;score)
    switch score &gt; 60 {
    case true:
        fmt.Println(&quot;&#x53CA;&#x683C;&quot;)
    case false:
        fmt.Println(&quot;&#x4E0D;&#x53CA;&#x683C;&quot;)
    }
}

func main() {
    //&#x6839;&#x636E;&#x8F93;&#x5165;&#x7684;&#x5E74;&#x4EFD;&#x6708;&#x4EFD; &#x8BA1;&#x7B97;&#x8FD9;&#x4E2A;&#x6708;&#x6709;&#x591A;&#x5C11;&#x5929;

    var y int
    var m int
    fmt.Scan(&amp;y, &amp;m)

    //&#x5728;switch&#x8BED;&#x53E5;&#x4E2D;&#x53EF;&#x4EE5;&#x628A;&#x76F8;&#x540C;&#x7684;&#x503C;&#x653E;&#x5728;&#x4E00;&#x4E2A;case&#x4E2D;
    switch m {
    case 1, 3, 5, 7, 8, 10, 12:
        fmt.Println(31)
    case 4, 6, 9, 11:
        fmt.Println(30)
    //fallthrough &#x5728;case&#x4E2D;&#x5411;&#x4E0B;&#x6267;&#x884C;&#x4E0B;&#x4E00;&#x4E2A;case
    //case 1:
    //    fallthrough
    //case 3:
    //    fallthrough
    //case 5:
    //    fallthrough
    //case 7:
    //    fallthrough
    //case 8:
    //    fallthrough
    //case 10:
    //    fallthrough
    //case 12:
    //    fmt.Println(31)
    //
    //case 4:
    //    fallthrough
    //case 6:
    //    fallthrough
    //case 9:
    //    fallthrough
    //case 11:
    //    fmt.Println(30)
    case 2:
        //&#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x95F0;&#x5E74;  &#x80FD;&#x88AB;4&#x6574;&#x9664; &#x4F46;&#x662F; &#x4E0D;&#x80FD;&#x88AB;100&#x6574;&#x9664;  &#x6216; &#x80FD;&#x88AB;400&#x6574;&#x9664;
        if y%4 == 0 &amp;&amp; y%100 != 0 || y%400 == 0 {
            fmt.Println(29)
        } else {
            fmt.Println(28)
        }

    default:
        fmt.Println(&quot;&#x6708;&#x4EFD;&#x8F93;&#x5165;&#x9519;&#x8BEF;&quot;)
    }
}

//case 3:
//    fmt.Println(31)
//case 4:
//    fmt.Println(30)
//case 5:
//    fmt.Println(31)
//case 6:
//    fmt.Println(30)
//case 7:
//    fmt.Println(31)
//case 8:
//    fmt.Println(31)
//case 9:
//    fmt.Println(30)
//case 10:
//    fmt.Println(31)
//case 11:
//    fmt.Println(30)
//case 12:
//    fmt.Println(31)
</code></pre><h2 id="4:_if&#x548C;switch&#x6BD4;&#x8F83;">4. 4: if&#x548C;switch&#x6BD4;&#x8F83;</h2>
<pre class="language-"><code>package main

func main() {


    //&#x4F18;&#x70B9;
    //if &#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x533A;&#x95F4;&#x5224;&#x65AD; &#x5D4C;&#x5957;&#x4F7F;&#x7528;
    //switch &#x6267;&#x884C;&#x6548;&#x7387;&#x9AD8; &#x53EF;&#x4EE5;&#x5C06;&#x591A;&#x4E2A;&#x6EE1;&#x8DB3;&#x76F8;&#x540C;&#x6761;&#x4EF6;&#x7684;&#x503C;&#x653E;&#x5728;&#x4E00;&#x8D77;

    //&#x7F3A;&#x70B9;
    //if &#x6267;&#x884C;&#x6548;&#x7387;&#x4F4E;
    //switch &#x4E0D;&#x5EFA;&#x8BAE;&#x5D4C;&#x5957;&#x4F7F;&#x7528;
}
</code></pre><h2 id="5:_&#x5FAA;&#x73AF;&#x8BED;&#x53E5;">5. 5: &#x5FAA;&#x73AF;&#x8BED;&#x53E5;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main() {

    //for i := 0; i &lt; 5; i++ {
    //    fmt.Println(&quot;6666&quot;)
    //}

    //for i := 1; i &lt;= 10; i++ {
    //    fmt.Println(i)
    //}

    //&#x8BA1;&#x7B97;1-100&#x548C;
    //sum := 0
    //for i := 1; i &lt;= 100; i++ {
    //    sum += i
    //}
    //
    //fmt.Println(sum)

    //&#x8BA1;&#x7B97;1-100&#x5076;&#x6570;&#x7684;&#x548C;
    //&#x5728;for&#x8BED;&#x53E5;&#x4E2D;&#x5D4C;&#x5957;if&#x6761;&#x4EF6;&#x5224;&#x65AD;
    //sum := 0
    //for i := 1; i &lt;= 100; i++ {
    //    if i%2 == 0 {
    //        sum+=i
    //    }
    //}
    //
    //fmt.Println(sum)
    //&#x8BA1;&#x7B97;1-100&#x5076;&#x6570;&#x7684;&#x548C;
    sum := 0
    for i := 0; i &lt;= 100; i += 2 {
        sum += i
    }

    fmt.Println(sum)

}
</code></pre><h2 id="6:_&#x5FAA;&#x73AF;&#x7EC3;&#x4E60;">6. 6: &#x5FAA;&#x73AF;&#x7EC3;&#x4E60;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0601() {

    //&#x6572;7 7&#x7684;&#x500D;&#x6570; &#x4E2A;&#x4F4D;&#x4E3A;7 &#x5341;&#x4F4D;&#x4E3A;7 &#x9700;&#x8981;&#x6572;&#x684C;&#x5B50;  1-100

    for i := 1; i &lt;= 100; i++ {
        if i%7 == 0 || i%10 == 7 || i/10 == 7 {
            fmt.Println(&quot;&#x6572;&#x684C;&#x5B50;&quot;)
        } else {
            fmt.Println(i)
        }
    }

}

func main0602() {
    //&#x6C34;&#x4ED9;&#x82B1;&#x6570;  &#x4E00;&#x4E2A;&#x4E09;&#x4F4D;&#x6570; &#x5404;&#x4E2A;&#x4F4D;&#x6570;&#x7684;&#x7ACB;&#x65B9;&#x548C;&#x7B49;&#x4E8E;&#x8FD9;&#x4E2A;&#x6570;&#x672C;&#x8EAB;
    for i := 100; i &lt;= 999; i++ {
        //&#x767E;&#x4F4D;
        a := i / 100
        //&#x5341;&#x4F4D;
        b := i / 10 % 10 //b:=i%100/10
        //&#x4E2A;&#x4F4D;
        c := i % 10

        if a*a*a + b*b*b + c*c*c == i {
            fmt.Println(i)
        }
    }

}
</code></pre><h2 id="7:_07&#x5FAA;&#x73AF;&#x5D4C;&#x5957;">7. 7: 07&#x5FAA;&#x73AF;&#x5D4C;&#x5957;</h2>
<pre class="language-"><code>package main

import (
    &quot;fmt&quot;
    &quot;time&quot;
)

func main0701() {
    //&#x4EE3;&#x7801;&#x5BF9;&#x9F50; ctrl+alt+l
    count := 0
    //&#x5916;&#x5C42;&#x6267;&#x884C;&#x4E00;&#x6B21; &#x5185;&#x5C42;&#x6267;&#x884C;&#x4E00;&#x5468;
    for i := 0; i &lt; 5; i++ {
        //fmt.Println(i)
        for j := 0; j &lt; 5; j++ {
            count++
            fmt.Println(i, j)
        }
    }

    fmt.Println(count)
}

//&#x7535;&#x5B50;&#x65F6;&#x949F;
func main0702() {
    //&#x65F6;
    for i := 0; i &lt; 24; i++ {
        //&#x5206;
        for j := 0; j &lt; 60; j++ {
            //&#x79D2;
            for k := 0; k &lt; 60; k++ {
                //&#x7A0B;&#x5E8F;&#x6682;&#x505C;
                time.Sleep(time.Millisecond * 950)
                //fmt.Println(i, j, k)
                fmt.Printf(&quot;%d &#x65F6; %d &#x5206; %d &#x79D2;\n&quot;, i, j, k)
            }
        }
    }
}

//func main() {
//    fmt.Println(time.Now())
//    fmt.Println(time.Now().Second())
//    fmt.Println(time.Now().Day())
//    fmt.Println(time.Now().Month())
//    //&#x8FD9;&#x4E00;&#x9762;&#x5DF2;&#x7ECF;&#x8FC7;&#x4E86;240&#x5929;&#x4E86;
//    fmt.Println(time.Now().YearDay())
//}

func main() {
    //&#x4E5D;&#x4E5D;&#x4E58;&#x6CD5;&#x53E3;&#x8BC0;
    /*
    1*1=1
    1*2=2 2*2=4
    1*3=3 2*3=6 3*3=9
     */
    // &#x5916;&#x5C42;&#x63A7;&#x5236;&#x884C;
    for i := 1; i &lt;= 9; i++ {
        //&#x5185;&#x5C42;&#x63A7;&#x5236;&#x5217;
        for j := 1; j &lt;= i; j++ {
            //&#x5982;&#x679C;&#x4EE3;&#x7801;&#x6EE1;&#x8DB3;&#x6761;&#x4EF6;&#x5C31;&#x8DF3;&#x51FA;
            //if j &gt; i {
            //    //&#x8DF3;&#x51FA;&#x8BED;&#x53E5;  &#x53EF;&#x4EE5;&#x8DF3;&#x51FA;&#x672C;&#x5C42;&#x5FAA;&#x73AF;
            //    break
            //}
            fmt.Printf(&quot;%d*%d=%d\t&quot;, j, i, i*j)
        }
        fmt.Println()
    }

}

//&#x6253;&#x5370;&#x7B49;&#x8170;&#x4E09;&#x89D2;&#x5F62;
//     *
//    ***
//   *****
//  *******
// *********
//***********
</code></pre><h2 id="8__08&#x767E;&#x94B1;&#x767E;&#x9E21;">8. 8. 08&#x767E;&#x94B1;&#x767E;&#x9E21;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0801() {
    /*
    &#x4E2D;&#x56FD;&#x53E4;&#x4EE3;&#x6570;&#x5B66;&#x5BB6;&#x5F20;&#x4E18;&#x5EFA;&#x5728;&#x4ED6;&#x7684;&#x300A;&#x7B97;&#x7ECF;&#x300B;&#x4E2D;&#x63D0;&#x51FA;&#x4E86;&#x4E00;&#x4E2A;&#x8457;&#x540D;&#x7684;&#x201C;&#x767E;&#x94B1;&#x767E;&#x9E21;&#x95EE;&#x9898;&#x201D;&#xFF1A;
    &#x4E00;&#x53EA;&#x516C;&#x9E21;&#x503C;&#x4E94;&#x94B1;&#xFF0C;&#x4E00;&#x53EA;&#x6BCD;&#x9E21;&#x503C;&#x4E09;&#x94B1;&#xFF0C;&#x4E09;&#x53EA;&#x5C0F;&#x9E21;&#x503C;&#x4E00;&#x94B1;&#xFF0C;
    &#x73B0;&#x5728;&#x8981;&#x7528;&#x767E;&#x94B1;&#x4E70;&#x767E;&#x9E21;&#xFF0C;&#x8BF7;&#x95EE;&#x516C;&#x9E21;&#x3001;&#x6BCD;&#x9E21;&#x3001;&#x5C0F;&#x9E21;&#x5404;&#x591A;&#x5C11;&#x53EA;&#xFF1F;
     */

    //cock hen chicken
    count := 0
    for cock := 0; cock &lt;= 20; cock++ {
        for hen := 0; hen &lt;= 33; hen++ {
            for chicken := 0; chicken &lt;= 100; chicken += 3 {
                count++
                //&#x4E09;&#x79CD;&#x9E21;&#x4E2A;&#x6570;&#x4E3A;100 &#x4EF7;&#x683C;&#x4E3A;100
                if cock+hen+chicken == 100 &amp;&amp; 5*cock+3*hen+chicken/3 == 100 {
                    fmt.Printf(&quot;&#x516C;&#x9E21;&#xFF1A;%d  &#x6BCD;&#x9E21;&#xFF1A;%d  &#x5C0F;&#x9E21;&#xFF1A;%d\n&quot;, cock, hen, chicken)
                }

            }
        }

    }

    fmt.Println(&quot;&#x6267;&#x884C;&#x6B21;&#x6570;&quot;, count)
}
func main() {

    count:=0
    for cock := 0; cock &lt;= 20; cock++ {
        for hen := 0; hen &lt;= 33; hen++ {
            count++
            //&#x5C0F;&#x9E21;&#x4E2A;&#x6570;&#x4E3A;100-&#x516C;&#x9E21;-&#x6BCD;&#x9E21;
            chicken := 100 - cock - hen
            if chicken%3==0 &amp;&amp; 5*cock+3*hen+chicken/3 == 100 {
                fmt.Printf(&quot;&#x516C;&#x9E21;&#xFF1A;%d  &#x6BCD;&#x9E21;&#xFF1A;%d  &#x5C0F;&#x9E21;&#xFF1A;%d\n&quot;, cock, hen, chicken)

            }
        }
    }

    fmt.Println(count)
}
//72114  24308 714
</code></pre><h2 id="9__09&#x8DF3;&#x51FA;&#x8BED;&#x53E5;">9. 9. 09&#x8DF3;&#x51FA;&#x8BED;&#x53E5;</h2>
<pre class="language-"><code>package main

import &quot;fmt&quot;

func main0901() {

    var i int = 0
    //&#x6B7B;&#x5FAA;&#x73AF;   &#x5FAA;&#x73AF;&#x6CA1;&#x6709;&#x51FA;&#x53E3;
    for {

        //&#x5728;&#x6709;&#x4E9B;&#x7A0B;&#x5E8F;&#x5FAA;&#x73AF;&#x4E2D; &#x4E0D;&#x77E5;&#x9053;&#x7A0B;&#x5E8F;&#x6267;&#x884C;&#x6B21;&#x6570;  &#x53EA;&#x6709;&#x6761;&#x4EF6;&#x6EE1;&#x8DB3;&#x65F6;&#x7A0B;&#x5E8F;&#x505C;&#x6B62;
        if i &gt;= 5 {
            //&#x8DF3;&#x51FA;&#x8BED;&#x53E5;&#x8DF3;&#x51FA;&#x5F53;&#x524D;&#x5FAA;&#x73AF;
            break
        }

        fmt.Println(i)

        i++
    }

}
func main0902() {

    sum := 0
    for i := 0; i &lt;= 100; i++ {
        if i%2 == 1 {
            //&#x7ED3;&#x675F;&#x672C;&#x6B21;&#x5FAA;&#x73AF; &#x7EE7;&#x7EED;&#x4E0B;&#x6B21;&#x5FAA;&#x73AF;
            //&#x5982;&#x679C;&#x5728;&#x7A0B;&#x5E8F;&#x4E2D;&#x5165;&#x5230;continue&#x540E;&#x5269;&#x4F59;&#x4EE3;&#x7801;&#x4E0D;&#x4F1A;&#x6267;&#x884C; &#x4F1A;&#x56DE;&#x5230;&#x5FAA;&#x73AF;&#x7684;&#x4F4D;&#x7F6E;
            continue
        }

        sum += i

    }

    fmt.Println(sum)
}
func main() {

    //fmt.Println(&quot;hello world1&quot;)
    //fmt.Println(&quot;hello world2&quot;)
    ////&#x5982;&#x679C;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x5165;&#x5230;goto &#x4F1A;&#x8DF3;&#x5230;&#x6240;&#x5B9A;&#x4E49;&#x7684;&#x6807;&#x5FD7;&#x4F4D;
    ////&#x53EF;&#x4EE5;&#x5728;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;&#x4E2D;&#x8DF3;&#x5230;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x5FAA;&#x73AF;&#x4E2D;  &#x53EF;&#x4EE5;&#x5728;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x4E2D;&#x8DF3;&#x5230;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x4E2D;
    //goto FLAG
    //fmt.Println(&quot;hello world3&quot;)
    //fmt.Println(&quot;hello world4&quot;)
    //FLAG:
    //fmt.Println(&quot;hello world5&quot;)
    //fmt.Println(&quot;hello world6&quot;)

    //&#x6B7B;&#x5FAA;&#x73AF;
FLAG:
    fmt.Println(&quot;hello world1&quot;)
    goto FLAG
    fmt.Println(&quot;hello world2&quot;)
}
</code></pre><p>&#x7EC3;&#x4E60;&#x9898;&#x7B54;&#x6848;&#xFF1A;</p>
<pre class="language-"><code>
package main

import &quot;fmt&quot;

//&#x6253;&#x5370;&#x7B49;&#x8170;&#x4E09;&#x89D2;&#x5F62;
//     *        5 6-i-1        1 i*2+1
//    ***        4 6-i-1        3 i*2+1
//   *****        3 6-i-1        5 i*2+1
//  *******        2 6-i-1        7 i*2+1
// *********    1 6-i-1        9 i*2+1
//***********    0 6-i-1        11 i*2+1
func main() {

    //&#x884C;&#x6570;
    l := 6

    //&#x6574;&#x4F53;&#x6267;&#x884C;&#x6B21;&#x6570;
    for i := 0; i &lt; l; i++ {
        //&#x63A7;&#x5236;&#x7A7A;&#x683C;&#x4E2A;&#x6570;
        for j := 0; j &lt; l-i-1; j++ {
            fmt.Print(&quot; &quot;)
        }
        //&#x63A7;&#x5236;&#x661F;&#x661F;&#x4E2A;&#x6570;
        for k := 0; k &lt; i*2+1; k++ {
            fmt.Print(&quot;*&quot;)
        }
        fmt.Println()
    }

}
</code></pre><footer class="page-footer"><span class="copyright">Copyright &#xA9; shxdledu.cn 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-11-07 00:57:04
</span></footer><div id="anchors-navbar"><i class="fa fa-anchor"></i><ul><p><a href="#&#x7B2C;&#x516B;&#x7AE0;&#xFF1A;&#x6D41;&#x7A0B;&#x63A7;&#x5236;">&#x7B2C;&#x516B;&#x7AE0;&#xFF1A;&#x6D41;&#x7A0B;&#x63A7;&#x5236;</a></p><li><a href="#1:_01if&#x6761;&#x4EF6;&#x8BED;&#x53E5;">1. 1: 01if&#x6761;&#x4EF6;&#x8BED;&#x53E5;</a></li><li><a href="#2:if&#x8BED;&#x53E5;&#x5D4C;&#x5957;">2. 2:if&#x8BED;&#x53E5;&#x5D4C;&#x5957;</a></li><li><a href="#3:switch&#x5206;&#x652F;&#x8BED;&#x53E5;">3. 3:switch&#x5206;&#x652F;&#x8BED;&#x53E5;</a></li><li><a href="#4:_if&#x548C;switch&#x6BD4;&#x8F83;">4. 4: if&#x548C;switch&#x6BD4;&#x8F83;</a></li><li><a href="#5:_&#x5FAA;&#x73AF;&#x8BED;&#x53E5;">5. 5: &#x5FAA;&#x73AF;&#x8BED;&#x53E5;</a></li><li><a href="#6:_&#x5FAA;&#x73AF;&#x7EC3;&#x4E60;">6. 6: &#x5FAA;&#x73AF;&#x7EC3;&#x4E60;</a></li><li><a href="#7:_07&#x5FAA;&#x73AF;&#x5D4C;&#x5957;">7. 7: 07&#x5FAA;&#x73AF;&#x5D4C;&#x5957;</a></li><li><a href="#8__08&#x767E;&#x94B1;&#x767E;&#x9E21;">8. 8. 08&#x767E;&#x94B1;&#x767E;&#x9E21;</a></li><li><a href="#9__09&#x8DF3;&#x51FA;&#x8BED;&#x53E5;">9. 9. 09&#x8DF3;&#x51FA;&#x8BED;&#x53E5;</a></li></ul></div><a href="#1:_01if&#x6761;&#x4EF6;&#x8BED;&#x53E5;" id="goTop"><i class="fa fa-arrow-up"></i></a>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../Chapter7/运算符.html" class="navigation navigation-prev " aria-label="Previous page: 第七章：运算符">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Chapter9/函数.html" class="navigation navigation-next " aria-label="Next page: 第九章：函数">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第八章：流程控制","level":"1.9","depth":1,"next":{"title":"第九章：函数","level":"1.10","depth":1,"path":"Chapter9/函数.md","ref":"Chapter9/函数.md","articles":[]},"previous":{"title":"第七章：运算符","level":"1.8","depth":1,"path":"Chapter7/运算符.md","ref":"Chapter7/运算符.md","articles":[]},"dir":"ltr"},"config":{"plugins":["toggle-chapters","sectionx","tbfed-pagefooter","include-codeblock","splitter","mermaid","codeblock-filename","prism","-highlight","simple-page-toc","navigator"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy shxdledu.cn 2018","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"splitter":{},"search":{},"mermaid":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{},"codeblock-filename":{},"navigator":{},"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"波波","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":" GO语言 web服务器区块链开发工程师就业班课程","language":"zh-hans","links":{"sidebar":{"关于作者":"http://www.shxdledu.cn/single/About-Me"}},"gitbook":"*","description":" GO语言 web服务器区块链开发工程师就业班课程"},"file":{"path":"Chapter8/流程控制.md","mtime":"2019-11-06T16:57:04.454Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-11-06T17:01:48.340Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

